"""
URL configuration for mailai project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/4.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from core import views as core_views
from core import run_views

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', core_views.dashboard, name='dashboard'),
    path('scenes/', core_views.scenes, name='scenes'),
    path('mailboxes/', core_views.mailboxes, name='mailboxes'),
    path('runs/', core_views.runs, name='runs'), # 运行日志
    path('debug/trigger-merge/', core_views.debug_trigger_merge, name='debug_trigger_merge'),
    path('runs/single', core_views.run_single, name='run_single'),
    path('run', run_views.run_center, name='run_center'),
    path('run/start', run_views.run_start, name='run_start'),
    path('run/daemon/start', run_views.run_daemon_start, name='run_daemon_start'),
    path('run/daemon/stop', run_views.run_daemon_stop, name='run_daemon_stop'),
    # 通用数据浏览与CRUD
    path('browse/', run_views.browse_router, name='browse_model'),
    path('browse/<str:model_key>/', run_views.browse_router, name='browse_model'),
    path('browse/<str:model_key>/<int:pk>/', lambda r, model_key, pk: run_views.browse_router(r, model_key, pk, 'detail'), name='browse_detail'),
    path('browse/<str:model_key>/<int:pk>/edit/', lambda r, model_key, pk: run_views.browse_router(r, model_key, pk, 'edit'), name='browse_edit'),
    path('browse/<str:model_key>/create/', lambda r, model_key: run_views.browse_router(r, model_key, None, 'create'), name='browse_create'),
    path('browse/<str:model_key>/<int:pk>/delete/', lambda r, model_key, pk: run_views.browse_router(r, model_key, pk, 'delete'), name='browse_delete'),
]
